# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@llvm-project//llvm:lit_test.bzl", "lit_test", "package_path")

package(
    default_visibility = [
        "//visibility:public",
    ],
)

expand_template(
    name = "lit_site_cfg_py",
    testonly = True,
    out = "lit.site.cfg.py",
    substitutions = {
        "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
        "@TORCH_MLIR_SOURCE_DIR@": package_path("@torch-mlir//:BUILD"),
        "\"@TORCH_MLIR_BINARY_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'torch-mlir')",
        "\"@LLVM_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'llvm-project', 'llvm')",
        # All disabled, but required to substituted because they are not in quotes.
        "@MLIR_ENABLE_BINDINGS_PYTHON@": "0",
        "@TORCH_MLIR_ENABLE_STABLEHLO@": "0",
        "@TORCH_MLIR_ENABLE_REFBACKEND@": "1",
    },
    template = "lit.site.cfg.py.in",
)

# Common data used by most lit tests.
filegroup(
    name = "lit_data",
    testonly = True,
    data = [
        "lit.cfg.py",
        "lit.site.cfg.py",
        "@llvm-project//llvm:FileCheck",
        "@llvm-project//llvm:count",
        "@llvm-project//llvm:not",
    ],
)
